Page({
  data: {
    loading: false
  },

  handleSubmit(e) {
    const { username, password } = e.detail.value
    
    if (!username || !password) {
      wx.showToast({
        title: '请输入账号和密码',
        icon: 'none'
      })
      return
    }

    this.setData({ loading: true })

    // 模拟登录请求
    setTimeout(() => {
      this.setData({ loading: false })
      wx.showToast({
        title: '登录成功',
        icon: 'success'
      })
      
      // 登录成功后跳转回原页面
      wx.navigateBack()
    }, 1500)
  },

  navigateToRegister() {
    wx.navigateTo({
      url: '/pages/register/register'
    })
  },

  navigateToForget() {
    wx.navigateTo({
      url: '/pages/forget/forget'
    })
  }
})
